package com.wallace.downloadserver

import com.wallace.downloadserver.interceptor.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

/**
 * @Description:
 * Web MVC 配置类
 * @author Wallace
 * @Date 2022/2/8 15:53
 */
@Configuration
class MyWebMvcConfig : WebMvcConfigurer {

    @Autowired
    private var multipleCallInterceptor: MultipleCallInterceptor? = null

    @Autowired
    private var timeStampInterceptor: TimeStampInterceptor? = null

    @Autowired
    private var tokenInterceptor: TokenInterceptor? = null

    override fun addInterceptors(registry: InterceptorRegistry) {
        registry.addInterceptor(multipleCallInterceptor!!)
                .addPathPatterns("/downloadserver/api/**")
        registry.addInterceptor(timeStampInterceptor!!)
                .addPathPatterns("/downloadserver/api/**")
        registry.addInterceptor(tokenInterceptor!!)
                .addPathPatterns("/downloadserver/api/**")
    }
}